package com.jxc.jxc01.grc.web;

import com.jxc.jxc01.grc.dao.impl.ManifestDaoImpl;
import com.jxc.jxc01.grc.entity.Manifest;
import com.jxc.jxc01.grc.entity.RespResult;
import com.jxc.jxc01.grc.service.IManifestService;
import com.jxc.jxc01.grc.service.impl.IManifestServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(value = "/obscureMan")
public class ObscureManServlet extends HttpServlet {
    @Override
    protected void service
            (HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        System.out.println("sadfkjashdfk");

        IManifestService iManifestService = new IManifestServiceImpl();
        String numbering1 = request.getParameter("numbering");
        if (numbering1 != ""){
            int numbering = Integer.parseInt(numbering1);
            List<Manifest> manifests = iManifestService.queryById(numbering);
            System.out.println(manifests);
                RespResult result = new RespResult();
                result.setCode(0);
                result.setMessage("ok");
                result.setCount(manifests.size());
                result.setData(manifests);
                //创建session
                HttpSession session = request.getSession();
                session.setAttribute("manifests", result);
                response.sendRedirect("rukuqingdan.html");
        }else {
            response.sendRedirect("rukuqingdan.html");
        }
        out.close();
    }
}
